package leetcode_二分查找;

/**
 * 搜索二维矩阵
 * 算法：二分查找
 *
 * @author yezh
 * @date 2024/3/5 11:22
 */
public class _74 {

    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length, n = matrix[0].length;
        for (int i = 0, j = n - 1; i < m && j >= 0; ) {
            if (target == matrix[i][j]) return true;
            if (target < matrix[i][j]) --j;
            else ++i;
        }
        return false;
    }

}
